// 2025/5/24
// 过桥

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> nums(n);
    for(auto& num : nums) cin >> num;

    int pos = 0, count = 0;
    while(pos != n - 1)
    {
        int next = pos;
        for(int i = 1; i <= nums[pos] && pos + i < n; i++)
        {
            if(pos + i == n - 1)
            {
                next = pos + i;
                break;
            }
            if(nums[pos + i] > 0 && pos + i + nums[pos + i] > next + nums[next])
                next = pos + i;
        }
        if(next == pos)
        {
            cout << -1 << endl;
            return 0;
        }
        pos = next;
        count++;
    }
    cout << count << endl;
}
// 64 位输出请用 printf("%lld")